<?php

use Illuminate\Support\Facades\Route;
use Modules\Auth\Http\Controllers\RegisterController;
use Modules\Auth\Http\Controllers\LoginController;
use Modules\Auth\Http\Controllers\UserController;

Route::prefix('api/auth')->group(function () {
    // 注册
    Route::post('/register', [RegisterController::class, 'store']);
    // 登录
    Route::post('/login', [LoginController::class, 'login']);

    // 需要登录才能访问的路由
    Route::middleware('auth:sanctum')->group(function () {
        //给路由手动添加名字
        Route::post('/logout', [LoginController::class, 'logout'])->name('logout');
        Route::get('/me', [LoginController::class, 'me']);
        Route::post('/refresh', [LoginController::class, 'refresh']);
        Route::apiResource('users', UserController::class);
        Route::post('/users/{user}/lock', [UserController::class, 'lock'])->name('users.lock');
        Route::post('/users/{user}/unlock', [UserController::class, 'unlock']);

    });
});
